<template>
  <c-list-page
    ref="commonRef"
    :table-props="tableProps"
    :page-props="pageProps"
    @get-list="getList">
    <template #search>
      <c-search-item label="项目名称">
        <el-input
          v-model.trim="searchData.projectName"
          placeholder="请输入你想查询的项目名称"
          maxlength="50"
          @keyup.enter="search()"/>
      </c-search-item>
      <c-search-item label="消息类型">
        <el-select
          v-model="searchData.messageType"
          placeholder="请选择"
          clearable
          style="width: 200px;"
          @change="search()">
          <el-option label="补充调研" :value="false" />
          <el-option label="信息更正" :value="true" />
        </el-select>
      </c-search-item>
    </template>
    <template #table>
      <el-table-column label="序号" type="index" width="55" />
      <el-table-column label="消息类型" prop="messageType" min-width="130" />
      <el-table-column label="项目名称" min-width="180">
        <template #default="{ row }">
          <el-text type="warning">{{ row.projectName }}</el-text>
        </template>
      </el-table-column>
      <el-table-column label="保函品种" prop="guaranteeLetterType" min-width="120" />
      <el-table-column label="保函金额（元）" prop="guaranteeLetterAmount" min-width="120" />
      <el-table-column label="消息内容" min-width="120">
        <template #default="{ row }">
          <el-text
            type="warning" style="cursor: pointer;"
            @click="handleDetail"
          >点击查看</el-text>
        </template>
      </el-table-column>
      <el-table-column label="消息发生时间" prop="messagePushTime" min-width="160" />
      <el-table-column label="消息处理时间" prop="messageDealTime" min-width="160" />
    </template>
  </c-list-page>

  <Detail v-model="visibleDetail" />
</template>

<script setup>
// 消息内容详情
import Detail from './components/detail.vue'
import useTableFn from '@/hooks/useTableCommon'
const {
  commonRef,
  tableProps,
  pageProps,
  searchData,
  search,
  operateSearch
} = useTableFn()

onMounted(() => {
  search()
})

const tableData = [{
    id: '1',
    messageType: '补充调研',
    projectName: '项目名称a',
    guaranteeLetterType: '履约保函',
    guaranteeLetterAmount: '300000',
    messagePushTime: '2025-3-17 14:20:07',
    messageDealTime: '',
  },
  {
    id: '2',
    messageType: '信息更正',
    projectName: '项目名称a',
    guaranteeLetterType: '履约保函',
    guaranteeLetterAmount: '300000',
    messagePushTime: '2025-3-17 14:20:07',
    messageDealTime: '',
  },
  {
    id: '3',
    messageType: '信息更正',
    projectName: '项目名称a',
    guaranteeLetterType: '履约保函',
    guaranteeLetterAmount: '300000',
    messagePushTime: '2025-3-17 14:20:07',
    messageDealTime: '',
  },
  {
    id: '4',
    messageType: '补充调研',
    projectName: '项目名称a',
    guaranteeLetterType: '履约保函',
    guaranteeLetterAmount: '300000',
    messagePushTime: '2025-3-17 14:20:07',
    messageDealTime: '',
  },
  {
    id: '5',
    messageType: '补充调研',
    projectName: '项目名称a',
    guaranteeLetterType: '履约保函',
    guaranteeLetterAmount: '300000',
    messagePushTime: '2025-3-17 14:20:07',
    messageDealTime: '',
  },
  {
    id: '6',
    messageType: '信息更正',
    projectName: '项目名称a',
    guaranteeLetterType: '履约保函',
    guaranteeLetterAmount: '300000',
    messagePushTime: '2025-3-17 14:20:07',
    messageDealTime: '',
  },
  {
    id: '7',
    messageType: '补充调研',
    projectName: '项目名称a',
    guaranteeLetterType: '履约保函',
    guaranteeLetterAmount: '300000',
    messagePushTime: '2025-3-17 14:20:07',
    messageDealTime: '',
  },
  {
    id: '8',
    messageType: '补充调研',
    projectName: '项目名称a',
    guaranteeLetterType: '履约保函',
    guaranteeLetterAmount: '300000',
    messagePushTime: '2025-3-17 14:20:07',
    messageDealTime: '',
  },
  {
    id: '9',
    messageType: '信息更正',
    projectName: '项目名称a',
    guaranteeLetterType: '履约保函',
    guaranteeLetterAmount: '300000',
    messagePushTime: '2025-3-17 14:20:07',
    messageDealTime: '',
  },
  {
    id: '10',
    messageType: '信息更正',
    projectName: '项目名称a',
    guaranteeLetterType: '履约保函',
    guaranteeLetterAmount: '300000',
    messagePushTime: '2025-3-17 14:20:07',
    messageDealTime: '',
  },
  {
    id: '11',
    messageType: '信息更正',
    projectName: '项目名称a',
    guaranteeLetterType: '履约保函',
    guaranteeLetterAmount: '300000',
    messagePushTime: '2025-3-17 14:20:07',
    messageDealTime: '',
  },
  {
    id: '12',
    messageType: '补充调研',
    projectName: '项目名称a',
    guaranteeLetterType: '履约保函',
    guaranteeLetterAmount: '300000',
    messagePushTime: '2025-3-17 14:20:07',
    messageDealTime: '',
  }
]

const getList = async val => {
  let params = {
    ...val,
  }
  console.log(params)
  try {
    tableProps.value.data = tableData
    pageProps.value.total = 80
    commonRef.value.tableLoading = false
    // const { code, data } = await dictType(params)
    // if (code == 0) {
    //   tableProps.value.data = (data && data.records) || []
    //   pageProps.value.total = (data && data.total) || 0
    //   commonRef.value.tableLoading = false
    // }
  } catch (error) {
    commonRef.value.tableLoading = false
  }
}

// 详情
const visibleDetail = ref(false)
function handleDetail() {
  visibleDetail.value = true
}
</script>

<style>
</style>
